package com.soso.dao;

import java.security.Timestamp;
import java.util.Date;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.soso.entity.Userroles;
import com.soso.entity.Users;


public interface UsersDao extends JpaRepository<Users, String>,JpaSpecificationExecutor<Users> {

	//查询所有
		@Query(value="select * from users where id=?1",nativeQuery = true)
		 public Users getallss(String id);
	
	//根据id所有
	@Query(value="select * from users where id=?1",nativeQuery = true)
	 public List<Users> getalls(String id);
	
	
	//登陆
	@Query(value="select * from users where LoginName=?1 and Password=?2",nativeQuery = true)
	public Users getlogin(String LoginName,String Password);
	//登陆修改登陆时间
	@Transactional	  
	 @Modifying	
	 @Query(value="update users set LastLoginTime=NOW() where Id=?1",nativeQuery = true)
	  public Integer orisLockoutlogin(String Id);
	
	
//修改是否锁定
	@Transactional	  
	 @Modifying	
	 @Query(value="update users set IsLockout=?1,LockTime=NOW() where Id=?2",nativeQuery = true)
	  public Integer orisLockout(String IsLockout,String Id);
	
	//修改是否锁定
		@Transactional	  
		 @Modifying	
		 @Query("update Users s set s.IsLockout=?1,LockTime=null where s.Id=?2")
		  public Integer orisLockouts(String IsLockout,String Id);
	//修改用户姓名，手机号 
	
	@Transactional	  
	 @Modifying	
	 @Query("update Users set LoginName=?1,ProtectEMail=?2,protectMTel=?3  where Id=?4")
	  public Integer xguserslpp(String LoginName,String ProtectEMail,String protectMTel,String Id);
	
	@Transactional	  
	 @Modifying	
	 @Query("delete from Users where Id=?1")
	  public Integer deluserslpp(String Id);
	
	//重置密码
	@Transactional
	@Modifying
	@Query("update Users s set s.Password='123456' where Id=?1")
	public Integer editpass(String Id);
	 
	
}
